#include "serversocket.h"
#include <iostream>

ServerSocket::ServerSocket(ISocketHandler& h) : TcpSocket(h)
, m_replyHandler(0)
, m_botHandler(0)
{
        SetLineProtocol();
        m_cmd = "TIME";
}

ServerSocket::~ServerSocket()
{
}

void ServerSocket::OnConnect()
{
        if (!m_cmd.empty())
                Send(m_cmd + "\n");


}

void ServerSocket::OnLine(const std::string& line)
{
        // send reply "line" to a rtmon
        if (m_replyHandler)
                m_replyHandler->reply(line);
        else if (m_botHandler)
                m_botHandler->reply(line);
        if (line.size())
        {
        }
        else
        {
                SetCloseAndDelete();
        }
}